<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".detail").colorbox({width:"70%", height:"60%", iframe:true});
	$(".audit").click(function(){
		if ( ! confirm("确定审核分销入库单？"))
		{
			return false;
		}
	});
	$("#check_all").click(function(){
		if ($(this).is(":checked"))
		{
			$(".list_table input[type='checkbox']:enabled").attr("checked", true);
		}
		else
		{
			$(".list_table input[type='checkbox']:enabled").attr("checked", false);
		}
	});
	$("#audit_btn").click(function(){
		if ( ! confirm("确定批量审核？"))
		{
			return false;
		}
		var ids = new Array();
		$(".list_table").find("input[type='checkbox']").each(function(){
			if ($(this).is(":checked"))
			{
				ids.push($(this).val());
			}
		});
		if (ids.length == 0)
		{
			alert("请选择订单");
			return false;
		}
		$("#ids").val(ids);
		$("#action_form").submit();
	});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>创建日期</th>
	<td>
		<input type="text" class="datepicker" name="begin_create_time" value="<?=isset($_GET['begin_create_time'])?$_GET['begin_create_time']:''?>" /> to 
		<input type="text" class="datepicker" name="end_create_time" value="<?=isset($_GET['end_create_time'])?$_GET['end_create_time']:''?>" />
	</td>
</tr>
<tr>
	<th>财务审核时间</th>
	<td>
		<input type="text" class="datepicker" name="begin_finance_audit_time" value="<?=isset($_GET['begin_finance_audit_time'])?$_GET['begin_finance_audit_time']:''?>" /> to 
		<input type="text" class="datepicker" name="end_finance_audit_time" value="<?=isset($_GET['end_finance_audit_time'])?$_GET['end_finance_audit_time']:''?>" />
	</td>
</tr>
<tr>
	<th>产品信息</th>
	<td><input type="text" name="product" value="<?=isset($_GET['product'])?$_GET['product']:''?>" /></td>
</tr>
<tr>
	<th>财务审核</th>
	<td colspan="3">
		<label><input type="checkbox" name="finance_audit[1]" value="1" <?if (isset($_GET['finance_audit'][1]))echo "checked='checked'"?> /> 财务未审核</label>
		<label><input type="checkbox" name="finance_audit[2]" value="2" <?if (isset($_GET['finance_audit'][2]))echo "checked='checked'"?> /> 财务已审核</label>
	</td>
</tr>
<tr>
	<td></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form></fieldset>

<table width="100%" class="list_table">
<tr>
	<th width="30"></th>
	<th width="100">总成本</th>
	<th width="150">创建日期</th>
	<th width="150">财务审核时间</th>
	<th width="100">经办人</th>
	<th>备注</th>
	<th width="120">状态</th>
	<th width="100">操作</th>
</tr>
<?foreach ($distribution as $d):?>
<tr>
	<td><input type="checkbox" value="<?=$d['id'];?>" <?if ($d['finance_audit'] == Q::ini('custom_flag/other_io_finance_audit/audited/value')):?>disabled="disabled"<?endif;?>/></td>
	<td><?=number_format($d['cost_amount'], 2)?></td>
	<td><?=$d['create_time']?></td>
	<td><?=$d['finance_audit_time']?></td>
	<td><?=$d['user_name']?></td>
	<td align="left"><?=$d['notes']?></td>
	<td>
		<?=Helper_BSS_Normal::getIniOne('distribution_finance_audit', 'value', $d['finance_audit'], 'name')?><br/>
		<?=Helper_BSS_Normal::getIniOne('distribution_storage_audit', 'value', $d['storage_audit'], 'name')?>
	</td>
	<td>
		<?if ($d['finance_audit'] == Q::ini('custom_flag/distribution_finance_audit/audited/value')):?>
		<font color="#aaaaaa">审核</font>
		<?else:?>
		<a class="audit" href="<?=url('Finance::Business/DistributionAudit',array('ids'=>$d['id']))?>">审核</a>
		<?endif;?>
		<a class="detail" href="<?=url('Finance::Business/DistributionDetail', array('id' => $d['id']))?>">详细</a>
	</td>
</tr>
<?endforeach;?>
</table>
<?=$page?>
<label><input type="checkbox" id="check_all" /> 全选</label>
<input type="button" class="button" id="audit_btn" value="批量审核" />
搜索条件的总成本：RMB <strong><?=number_format($amount, 2)?></strong>
<form id="action_form" method="post" action="<?=url('Finance::Business/DistributionAudit')?>">
<input type="hidden" id="ids" name="ids"/>
</form>
<?php $this->_endblock();?>